home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / UNTIL.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  3KB  |  176 lines

  1. cseg    segment para public 'code'
  2.     org 100h
  3.  
  4. ; This program is used to cause the computer to wait until the
  5. ; specified time. For example, 'UNTIL 20:20' will cause the system
  6. ; to wait until 20:20 (8:20 PM).
  7.  
  8. until    proc far
  9.     assume cs:cseg,ds:cseg,ss:nothing,es:nothing
  10.  
  11.     mov si,80h        ; point to command line
  12.     mov ch,0
  13.     mov cl,[si]        ; get length
  14.     jcxz p010        ; it's zero
  15.     jmp p020
  16.  
  17. p010:    mov dx,offset msg1    ; print error
  18.     call p120
  19.     jmp p040        ; and quit
  20.  
  21. p020:    mov cx,10
  22.     call p140        ; get hours
  23.     cmp al,0
  24.     jb p010         ; too low
  25.     cmp al,23
  26.     ja p010         ; too high
  27.     mov untilhr,al
  28.     aam            ; convert to ascii
  29.     add ax,3030h
  30.     xchg ah,al
  31.     mov msg2hr,ax
  32.  
  33.     call p140        ; get minutes
  34.     cmp al,0
  35.     jb p010         ; too low
  36.     cmp al,59
  37.     ja p010         ; too high
  38.     mov untilmin,al
  39.     aam            ; convert to ascii
  40.     add ax,3030h
  41.     xchg ah,al
  42.     mov msg2min,ax
  43.  
  44.     mov ah,2        ; home the cursor
  45.     mov bh,0
  46.     mov dx,0
  47.     int 10h
  48.  
  49.     mov ax,600h        ; clear screen
  50.     mov bh,7
  51.     mov cx,0
  52.     mov dx,184fh
  53.     int 10h
  54.  
  55.     mov dx,offset copyr    ; print copyright
  56.     call p120
  57.  
  58.     mov dx,offset msg2    ; print target time
  59.     call p120
  60.  
  61.     mov dx,offset msg3    ; print current time
  62.     call p120
  63.  
  64.     mov ah,3        ; get cursor position
  65.     mov bh,0
  66.     int 10h
  67.     mov coords,dx        ; save coordinates
  68.  
  69. p030:                ; loop til time is up
  70.     mov cx,0ffffh        ; kill time
  71. p031:    inc dx
  72.     loop p031
  73.  
  74.     mov ah,2        ; set cursor position
  75.     mov bh,0
  76.     mov dx,coords
  77.     int 10h
  78.  
  79.     mov ah,2ch        ; get time
  80.     int 21h
  81.  
  82.     mov al,ch
  83.     call p100        ; print hours
  84.     mov dl,':'
  85.     call p110        ; print colon
  86.     mov al,cl
  87.     call p100        ; print minutes
  88.     mov dl,':'
  89.     call p110        ; print colon
  90.     mov al,dh
  91.     call p100        ; print seconds
  92.  
  93.     mov ah,untilhr
  94.     mov al,untilmin
  95.     cmp ax,cx        ; done?
  96.     jnz p030        ; no
  97.  
  98. p040:    int 20h         ; terminate
  99.  
  100. p100    proc near        ; print number
  101.     push dx
  102.     push cx
  103.     mov dx,0
  104.     mov cx,10
  105.     mov ah,0
  106.     div cx
  107.     add dl,48
  108.     mov bl,dl
  109.     mov dx,0
  110.     div cx
  111.     add dl,48
  112.     call p110
  113.     mov dl,bl
  114.     call p110
  115.     pop cx
  116.     pop dx
  117.     ret
  118. p100    endp
  119.  
  120. p110    proc near        ; print char
  121.     push ax
  122.     mov ah,2
  123.     int 21h
  124.     pop ax
  125.     ret
  126. p110    endp
  127.  
  128. p120    proc near        ; print string
  129.     push ax
  130.     mov ah,9
  131.     int 21h
  132.     pop ax
  133.     ret
  134. p120    endp
  135.  
  136. p140    proc near        ; get hours & minutes
  137.     mov ax,0
  138.     cmp ch,0        ; end of line?
  139.     jnz p148        ; yes
  140.  
  141. p142:    inc si            ; point to next char
  142.     mov dl,[si]
  143.     cmp dl,':'              ; colon?
  144.     jz p148         ; yes
  145.     cmp dl,13        ; carriage return?
  146.     jz p147         ; yes
  147.     cmp dl,'0'
  148.     jb p142         ; < 0 - ignore it
  149.     cmp dl,'9'
  150.     ja p142         ; > 9 - ignore it
  151.     sub dl,'0'              ; convert to binary
  152.     mul cl            ; current contents of al times 10
  153.     add al,dl        ; add latest digit
  154.     jmp p142        ; get next one
  155.  
  156. p147:    inc ch            ; end of line
  157. p148:    ret
  158. p140    endp
  159.  
  160. copyr    db 'UNTIL - Copyright 1983 Data Base Decisions',10,13,'$'
  161. msg1    db 'Missing/Invalid time',07,10,13,'$'
  162. msg2    db 'Waiting until: '
  163. msg2hr    dw '00'
  164.     db ':'
  165. msg2min dw '00'
  166.     db 10,13,'$'
  167. msg3    db 'The time is  : $'
  168.  
  169. untilhr db 0            ; target hour & minute
  170. untilmin db 0
  171. coords    dw 0            ; cursor coords
  172.  
  173. until    endp
  174. cseg    ends
  175. end    until
  176.